<?php
	Aero::setOption('form.secret','SFHoi-832hrf0/au8a932');
	
	Aero::setOption('forms.test_form.text',array(
		'label'		=> 'Test text',
		'control'	=> 'text',
		'constraints' => 'required|longer_than[8]|shorter_than[16]',
		'default'	=> 'Enter some text',
		'control_class' => 'some-class some-other-class',
		'hint' => 'Fill this'
	));
	Aero::setOption('forms.test_form.textarea',array(
		'label'		=> 'Test textarea',
		'control'	=> 'textarea',
		'constraints' => 'required|numeric|greater_than[0]|less_than[100]',
		'cols'		=> 50,
		'rows'		=> 10,
		'default'	=> array('Enter some text','Enter different kind of text'),
		'multiple'	=> true
	));
	Aero::setOption('forms.test_form.password',array(
		'label'		=> 'Test password',
		'control'	=> 'password',
		'constraints' => 'required'
	));
	Aero::setOption('forms.test_form.file',array(
		'label'		=> 'Test file',
		'control'	=> 'file',
		'constraints' => 'required|allowed_type[gif,jpg,png]',
		'multiple'	=> true,
		'storage_depth' => 2
	));
	Aero::setOption('forms.test_form.select',array(
		'label'		=> 'Test select',
		'control'	=> 'select',
		'options'	=> array('' => 'Select some value',
			'Group 1' => array('jaga_g1' => 'Jaga','jiga_g1' => 'Jiga'),
			'Group 2' => array('jaga_g2' => 'Jaga','jiga_g2' => 'Jiga'),
			'jaga' => 'Jaga','jiga' => 'Jiga'),
		'multiple'	=> true
	));
	Aero::setOption('forms.test_form.radio',array(
		'label'		=> 'Test radio group',
		'control'	=> 'radio',
		'options'	=> array('gaga' => 'Gaga','jaga' => 'Jaga','jiga' => 'Jiga'),
		'default'	=> 'jaga'
	));
	Aero::setOption('forms.test_form.checkbox',array(
		'label'		=> 'Test checkbox',
		'control'	=> 'checkbox'
	));
	Aero::setOption('forms.test_form.multi_select',array(
		'label'		=> 'Test multi-select',
		'control'	=> 'multi_select',
		'options'	=> array('' => 'Select some value',
			'Group 1' => array('jaga_g1' => 'Jaga','jiga_g1' => 'Jiga'),
			'Group 2' => array('jaga_g2' => 'Jaga','jiga_g2' => 'Jiga'),
			'jaga' => 'Jaga','jiga' => 'Jiga'),
		'default'	=> array('jaga','jiga')
	));
	Aero::setOption('forms.test_form.multi_checkbox',array(
		'label'		=> 'Checkbox group',
		'control'	=> 'multi_checkbox',
		'options'	=> array('gaga' => 'Gaga','jaga' => 'Jaga','jiga' => 'Jiga'),
		'default'	=> array('jaga','jiga')
	));
	Aero::setOption('forms.test_form.date',array(
		'label'		=> 'Date',
		'control'	=> 'date',
		'default'	=> array('2010-11-30','2010-12-30'),
		'constraints' => 'required',
		'multiple'	=> true
	));
	Aero::setOption('forms.test_form.group',array(
		'label'		=> array(
			'Group control',
			'Group field'
		),
		'control'	=> 'group',
		'template'	=> '{text}<br>{select}<br>{date}',
		'multiple'	=> true,
		'controls'	=> array(
			'text' => array(
				'label'		=> 'Test text',
				'control'	=> 'text',
				'constraints' => 'required|longer_than[8]|shorter_than[16]',
				'default'	=> 'Enter some text',
				'control_class' => 'some-class some-other-class',
				'hint' => 'Enter some text longer than 8 characters'
			),
			'select' => array(
				'label'		=> 'Test select',
				'control'	=> 'select',
				'options'	=> array('' => 'Select some value',
					'Group 1' => array('jaga_g1' => 'Jaga','jiga_g1' => 'Jiga'),
					'Group 2' => array('jaga_g2' => 'Jaga','jiga_g2' => 'Jiga'),
					'jaga' => 'Jaga','jiga' => 'Jiga')
			),
			'date' => array(
				'label' => 'Test date',
				'control'=> 'date',
				'default' => '2010-13-01',
				'constraints' => 'required'
			)
		)
	));
	
	$form = Aero::load('libs/form','test_form');
	
	// if ($form->file->isUploadedRemotely())
	// {
	// 	echo $form->file->toJSON();
	// 	exit;
	// }
	
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
	"http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
	<meta http-equiv="Content-type" content="text/html; charset=utf-8">
	<title>Form stylesheet test</title>
	<!-- <script type="text/javascript" src="/scripts/mootools-1.2.2.js"></script>
	<script type="text/javascript" src="/scripts/file_upload.js"></script>
	<script type="text/javascript" charset="utf-8">
		window.addEvent('domready',function() {
			// new FileUpload('file-0-field');
		});
	</script> -->
	<style type="text/css" media="screen">
		@import '/styles/reset.css';
		@import '/styles/forms.css';
		
		/* Typography settings */
		body {
			font-size: 16px;
			line-height: 1.5; 
			padding: 1.5em;
			width: 40em;
/*			background: url(/images/testing/vertical_24.gif);*/
		}
		
		h1 {
			font-size: 24px;
			line-height: 1;
			margin-bottom: 1em;
		}
		h2 {
			font-size: 20px;
			line-height: 1.2;
			margin: 1.2em 0 0;
		}
		
	</style>
	<!--[if lte IE 7]><link rel="stylesheet" href="/styles/forms_ie.css" type="text/css" media="screen" title="no title" charset="utf-8"><![endif]-->
</head>
<body>
<h1>Test form<?= $form->isValid() ? ' (valid)' : '' ?></h1>
<?php

// if ($form->isValid())
// {
// 	$values = $form->values();
// 	var_dump($values);
// }

?>
<?= $form->open() ?>
	<?= $form->text() ?>
	<?= $form->textarea() ?>
	<?= $form->textarea() ?>
	<?= $form->password() ?>
	<?= $form->file() ?>
	<?= $form->file() ?>
	<?= $form->select() ?>
	<?= $form->radio() ?>
	<?= $form->checkbox() ?>
	<?= $form->multi_select() ?>
	<?= $form->multi_checkbox() ?>
	<?= $form->group() ?>
	<?= $form->group() ?>
	<?= $form->date() ?>
	<?= $form->date() ?>
<div class="field">
	<?= $form->button('Submit form') ?>
</div>
<?= $form->close() ?>
<?php
	// var_dump($_POST, $_FILES);
?>
</body>
</html>